package com.zhangyu.shadow;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.ActionBar;
import android.widget.Toast;

import com.tepth.shadow.ui.launcher.ILauncherListener;
import com.tepth.shadow.ui.launcher.OnLauncherFinishTag;
import com.zhangyu.shadow.core.activity.ProxyActivity;
import com.zhangyu.shadow.core.app.Shadow;
import com.zhangyu.shadow.core.delegate.ShadowDelegate;
import com.zhangyu.shadow.ec.laucher.LauncherDelegate;
import com.zhangyu.shadow.ec.main.ECBottomDelegate;
import com.zhangyu.shadow.ec.sign.ISignListener;
import com.zhangyu.shadow.ec.sign.SignInDelegate;

import hugo.weaving.DebugLog;
import qiu.niorgai.StatusBarCompat;

/**
 * @author zhangyu
 */
@DebugLog
public class ExampleActivity extends ProxyActivity implements
        ISignListener, ILauncherListener {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ActionBar actionBar = getSupportActionBar();
        if (actionBar != null) {
            actionBar.hide();
        }
        Shadow.getConfigurator().withActivity(this);
        StatusBarCompat.translucentStatusBar(this, true);
    }

    @Override
    public ShadowDelegate setRootDelegate() {
        return new LauncherDelegate();
    }

    @Override
    public void onSignInSuccess() {
        startWithPop(new ECBottomDelegate());
    }

    @Override
    public void onSignUpSuccess() {
        startWithPop(new ECBottomDelegate());
    }

    @Override
    public void onLauncherFinish(OnLauncherFinishTag tag) {
        switch (tag) {
            case SIGNED:
                Toast.makeText(this, "启动结束,用户登录了", Toast.LENGTH_LONG).show();
                startWithPop(new ECBottomDelegate());
                break;
            case NOT_SIGNED:
                Toast.makeText(this, "启动结束,用户没登录", Toast.LENGTH_LONG).show();
                startWithPop(new SignInDelegate());
                break;
            default:
                break;
        }
    }
}
